/* 最大流拆点
* 1.解题思路 
    建图：
        建立源点S, 向所有初始的点连边，容量为初始时点上企鹅的数量
        然后向所有能够相互到达的点之间连边，容量足够大，由于每个点之间也有限制，需要拆点-将每个点拆分为入点和出点
        入点向出点连边，容量为每个点的承受能力
        最后枚举汇合的点-汇点T，最后判断最大流是否满流即可


*/

#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
using namespace std;
const int N = 210, M = 20410, INF = 0x3f3f3f3f;
const double eps = 1e-8;
using PII = pair<int, int>;
#define x first
#define y second
int n, S, T;
int h[N], e[M], c[M], ne[M], idx;
int q[N], d[N], cur[N];

PII p[N]; double D;

void AddEdge(int a, int b, int w)
{
    e[idx] = b, c[idx] = w, ne[idx] = h[a], h[a] = idx++;
    e[idx] = a, c[idx] = 0, ne[idx] = h[b], h[b] = idx++;
}

bool bfs()
{
    memset(d, -1, sizeof d);
    int hh = 0, tt = -1;
    q[++tt] = S, d[S] = 0, cur[S] = h[S];
    while(hh <= tt)
    {
        int u = q[hh++];
        for(int i = h[u]; ~i; i = ne[i])
        {
            int v = e[i];
            if(d[v] == -1 && c[i])
            {
                d[v] = d[u]+1;
                cur[v] = h[v];
                if(v == T) return true;
                q[++tt] = v;
            }
        }
    }
    return false;
}

int find(int u, int limit)
{
    if(u == T) return limit;
    int flow = 0;
    for(int i = cur[u]; ~i && flow < limit; cur[u] = i, i = ne[i])
    {
        int v = e[i];
        if(d[v] == d[u] + 1 && c[i])
        {
            int t = find(v, min(c[i], limit-flow));
            if(!t) d[v] = -1;
            c[i] -= t, c[i^1] += t, flow += t;
        }
    }
    return flow;
}

int Dinic()
{
    int r = 0, flow;
    while(bfs())
        while(flow = find(S, INF)) r += flow;
    return r;
}

bool check(PII a, PII b)
{
    double dx = a.x -b.x, dy = a.y-b.y;
    return dx*dx + dy*dy < D * D + eps;
}

signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif

    int cases; cin >> cases;

    while(cases--)
    {
        memset(h, -1, sizeof h);
        idx = 0;
        cin >> n >> D;
        S = 0;
        int tot = 0; //总企鹅数
        for(int i = 1; i <= n; i++)
        {
            int a, b; cin >> p[i].x >> p[i].y >> a >> b; //坐标 浮冰上的企鹅数量 浮冰可以承受的起跳次数
            tot += a;
            AddEdge(S, i, a);
            AddEdge(i, n+i, b);
        }

        for(int i = 1; i <= n; i++)
            for(int j = i+1; j <= n; j++)
            if(check(p[i], p[j]))
            {
                AddEdge(n+i, j, INF);
                AddEdge(n+j, i, INF);
            }
        int cnt = 0; //合法冰块数量
        for(int i=1; i<=n; i++) //枚举终点
        {
            T = i; //将当前冰块作为终点
            for(int j = 0; j < idx; j+=2) //还原残留网络
            {
                c[j] += c[j^1];
                c[j^1] = 0;
            }
            if(Dinic() == tot)
            {
                printf("%d ", i-1);
                cnt ++;
            }
        }
        if(!cnt) puts("-1");
        else puts("");
    }
    return 0;
}